﻿using System;

namespace Postnuclear.Test.Helpers
  {
  /// <summary>
  /// Helper class for garbage collection.
  /// Main purpose if to provide compatibility for SilverLight tests.
  /// </summary>
  internal static class GarbageCollector
    {
    #region Public

    // Methods

    /// <summary>
    /// Collects garbage and waits for pending finalizers.
    /// </summary>
    public static void CollectAndWaitForPendingFinalizers()
      {
#if SILVERLIGHT
      GC.Collect();
#else
      GC.Collect(GC.MaxGeneration);
#endif
      GC.WaitForPendingFinalizers();
      }

    #endregion
    }
  }
